package edu.westga.movierec.XAMPPtests.reader;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import edu.westga.movierec.model.*;
/**
 * Test methods for {@link edu.westga.movierec.model.XamppDBConnector#deleteMovieFromUserHistory(int, String)
 * and addMovieToUserHistoryTests, #changeMovieRating(String, String, int)}.
 * 
 * @author Jean Cook, CS 6242, Fall 2009
 *
 */
public class DeleteUserMovieTests {
	private XamppDBConnector theDatabase;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		this.theDatabase = new XamppDBConnector();
	}
	//user there, movie not
	@Test
	public void isAlreadyRecShouldBeFalseWhenUser1MovieScream(){
		this.theDatabase.deleteMovieFromUserHistory(1,"Scream");
		assertEquals(this.theDatabase.isAlreadyRecommended(1, 1),false);
	}
	// user there, movie there
	@Test
	public void isAlreadyRecShouldBeFalseWhenUser1MovieSaw(){
		this.theDatabase.deleteMovieFromUserHistory(1,"Saw");
		assertEquals(this.theDatabase.isAlreadyRecommended(1,2),false);
	}
	//user not there, movie there
	@Test
	public void isAlreadyRecShouldBeFalseWhenUser22MovieSaw(){
		this.theDatabase.deleteMovieFromUserHistory(22,"Saw");
		assertEquals(this.theDatabase.isAlreadyRecommended(22,2),false);
	}
	//user and movie already there
	@Test
	public void isAlreadyRecShouldBeTrueWhenUser1movieTitanic(){
		this.theDatabase.addMovieToUserHistory(1,"Titanic");
		assertTrue(this.theDatabase.isAlreadyRecommended(1,3));
	}
	//user and movie not already there
	@Test
	public void isAlreadyRecShouldBeTrueWhenUser10movieSaw(){
		this.theDatabase.addMovieToUserHistory(10,"Saw");
		assertTrue(this.theDatabase.isAlreadyRecommended(10,2));
	}
	//Rating changes
	@Test
	public void getMovieRatingShouldBe25WhenInputSawOutputScreamNewRating25(){
		this.theDatabase.setMovieRating("Scream","Saw",25);
		assertEquals(this.theDatabase.getMovieRating("Scream","Saw"),25);
	}
	//Rating stays the same
	@Test
	public void getMovieRatingShouldBe10WhenInputSawOutputGhostbustersNewRating10(){
		this.theDatabase.setMovieRating("Saw","Ghostbusters",10);
		assertEquals(this.theDatabase.getMovieRating("Saw","Ghostbusters"),10);
	}
}
